package com.superm.controller;

import com.superm.entity.Emp;
import com.superm.entity.Order;
import com.superm.service.GoodsService;
import com.superm.service.OrderService;
import com.superm.utils.EmpContent;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(path = "/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private GoodsService goodsService;
    @RequestMapping(path = "/allOrder")
    @ResponseBody
    public Map<String, Object> allOrder(){
        Emp emp =EmpContent.EmpUtils();
        System.out.println(emp);
        Map<String, Object> map = new HashMap<>();
        map.put("code",0);
        List<Order> orders = orderService.allOrders(emp.geteId());
        map.put("data",orders);
        return map;
    }
    @RequestMapping(path = "/delOrder")
    @ResponseBody
    public Map<String,Object> delOrder(Order order){
        return orderService.delOrder(order);
    }
}
